package fluxx.draft;

import java.util.Collections;
import java.util.HashSet;
import java.util.NoSuchElementException;
import java.util.Set;


// I think maybe we don't need this class at all.
public abstract class Deck implements Iterable<Card> {
	private final Set<Card> cards = new HashSet<Card>();
	
	protected void add(Card card) {
		cards.add(card);
	}
	
	public Card getCard(String name) {
		for (Card card : cards) {
			if (card.getName().equals(name)) {
				return card;
			}
		}
		throw new NoSuchElementException();
	}
	
	/**
	 * Returns an immutable view of the complete deck,
	 * regardless of game state.
	 * @return All cards contained by this deck. 
	 */
	public Set<Card> getDeck () {
		return Collections.unmodifiableSet(cards);
	}
}
